<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">

    <title>登录</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">
    <link href="/Public/Admin/css/bootstrap.min.css" rel="stylesheet">
    <link href="/Public/Admin/css/font-awesome.css" rel="stylesheet">
    <link href="/Public/Admin/css/animate.css" rel="stylesheet">
    <link href="/Public/Admin/css/style.css" rel="stylesheet">
    <link href="/Public/Admin/css/login.css" rel="stylesheet">
    <link href="/Public/Admin/js/plugins/layer/skin/default/layer.css" rel="stylesheet">
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->
    <script>
        if (window.top !== window.self) {
            window.top.location = window.location;
        }
    </script>
    <style>
        .logopanel h1{font-size:35px; font-weight:300; text-shadow:1px 2px 8px #666;}
        #layui-layer1{box-shadow:0 0px 5px 0px #666; background:#fefefe; border-radius:5px;}
        .layui-layer-content{color:#333;}
    </style>

</head>

<body class="signin">
    <div class="signinpanel">
        <div class="row">
            <div class="col-sm-7">
                <div class="signin-info">
                    <div class="logopanel m-b">
                        <h1>欢迎登录PHP后台管理系统</h1>
                    </div>
                </div>
            </div>
            <div class="col-sm-5">
                <form method="post" action="<?php echo U('Login/doLogin');?>" id="doLogin">
                    <h4 class="no-margins">登录：</h4>
                    <p class="m-t-md">欢迎登录</p>
                    <input type="text" class="form-control uname" placeholder="用户名" name="username" id="username" />
                    <input type="password" class="form-control pword m-b" placeholder="密码" name="password" id="password"/>
                    <a href="">忘记密码了？</a>
                    <button class="btn btn-primary btn-block">登录</button>
                </form>
            </div>
        </div>
        <div class="signup-footer">
            <div class="pull-left">
        
            </div>
        </div>
    </div>
    <script type="text/javascript" src="/Public/Admin/js/jquery.min.js"></script>
    <script type="text/javascript" src="/Public/Admin/js/jquery.form.js"></script>
    <script type="text/javascript" src="/Public/Admin/js/plugins/layer/layer.js"></script>
    <script type="text/javascript" src="/Public/Admin/js/comment.js"></script>

    <script>
        $(function(){
            $('#doLogin').ajaxForm({
                beforeSubmit:checkForm,
                success:result,
                dataType:'json',
                clearForm:true
            });
        });
        function checkForm(){
            var userName = $('#username').val();
            var passWord = $('#password').val();
            if('' == userName ){
                //引入过layer.js能出现动画效果icon：5 哭脸 time:1000 停留时间1秒，anim：6 抖动
                comment.error('用户名不能为空!');
                comment.tips('用户名长度不能少于5位','#username');
                return false;
            } 
            if('' == passWord){
                comment.error('密码不能为空!');
                comment.tips('密码长度不能少于6位，最长位12位','#password');
                return false;
            }

            if(passWord.length < 6 || passWord.length > 15){
                comment.error('密码不符合长度');
                $('#password').val('').focus();
                return false;
            }
            $('button').removeClass('btn-primary').addClass('btn-success').attr('disabled','disabled').text('登录中...');
        }
        function result(data){
            if(data.status < 1){
                comment.error(data.mess);
                $('button').removeClass('btn-success').addClass('btn-primary').removeAttr('disabled').text('登录');
                return false;
            }
            //成功后再php处理页面传递过来的数组可以通过回调函数跳转
            // layer.msg(data.mess,{icon:6,time:2000,anim:5},function(){
            //     window.location.href = '/admin/';//也可以写U函数
            // });
            comment.success(data.mess,'/admin');
        }
    </script>
</body>
</html>